<?php
/**
 * Created by PhpStorm.
 * User: YSF
 * Date: 2017\10\17 0017
 * Time: 9:06
 */

namespace app\common\model;


use think\Db;
use think\Model;

/**
 * Class PartsInfo
 * @package app\common\model
 *        配件分类模型
 */
class PartsInfo extends Model
{

    /**
     * @return false|\PDOStatement|string|\think\Collection
     *     获取配件所有数据
     */
    public function getAll($nowPage, $limits)
    {
        $data = $this->page($nowPage,$limits)->select();
        return $data;
    }

    /**
     * @return int|string
     *     统计总的数据
     */
    public function getCount()
    {
        $count = $this->count();
        return $count;
    }

    /**
     * @param $where
     * @return false|\PDOStatement|string|\think\Collection
     *      根据条件查询单条数据
     */
    public function getOne($dbName, $where)
    {
        $data = Db::name($dbName)->where($where)->select();
        return $data;
    }
    /**
     * @param $where
     * @return int
     *     根据条件删除数据
     */
    public function remove($where)
    {
        $result = $this->where($where)->delete();
        return $result;
    }

    /**
     * @param $where
     * @param $update
     * @return $this
     *      根据条件修改数据
     */
    public function edit($data)
    {
        $where['id'] = $data['id'];
        $result = $this->where($where)->update(['name' => $data['name']]);
        return $result;
    }

}